import sun.text.resources.FormatData;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @PackageName: PACKAGE_NAME
 * @ClassName:
 * @author: wxc
 * @date 2021/5/26 DEMO2
 */
public class DEMO2 {
    public static void main(String[] args) {
        Date date = new Date();
        String date1 = "永久";
        Date endTime = getEndTime(date, date1);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(endTime));
    }

    private static Date getEndTime(Date date, String date1) {
        Long time = null;//30分钟
        if (date1.equals("30分钟")) {
            time = 30 * 60 * 1000L;
        } else if (date1.equals("一天")) {
            time = 24 * 60 * 60 * 1000L;
        } else if (date1.equals("一周")) {
            time = 7 * 24 * 60 * 60 * 1000L;
        } else if (date1.equals("一个月")) {
            time = 30 * 24 * 60 * 60 * 1000L;
        } else if (date1.equals("永久")) {
            time = 50 * 365 * 24 * 60 * 60 * 1000L;
        }
        Date afterDate = getDate(date, time);
        return afterDate;
    }

    private static Date getDate(Date date, Long time) {
        return new Date(date.getTime() + time);
    }
}
